package leetcode;

/**
 * 回文数
 */
public class LeetCode9 {
    public static void main(String[] args) {
        LeetCode9 l = new LeetCode9();
        System.out.println(l.isPalindrome(121));
    }

    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        int result = 0;
        int bak = x;
        while (x != 0) {
            int mod = x % 10;
            result = result * 10 + mod;
            x = x / 10;
        }
        System.out.println(result);
        return bak == result;
    }
}
